import { DataTableColumn } from "@/components/common/full-table";
import { NTag } from "naive-ui";

export const useTableColumns = () => {
  const columns: DataTableColumn<Role>[] = [
    {
      type: "selection",
      fixed: "left",
      key: "selection",
      width: 30,
      title: "选择框",
      lock: true,
    },
    {
      title: "序号",
      key: "no",
      width: 60,
      fixed: "left",
      align: "center",
      render(_, index) {
        return index + 1;
      },
    },
    {
      title: "名称",
      key: "name",
      width: 120,
      ellipsis: { tooltip: true },
    },
    {
      title: "标识",
      key: "code",
      width: 120,
      ellipsis: { tooltip: true },
    },
    {
      title: "状态",
      key: "status",
      width: 120,
      ellipsis: { tooltip: true },
      render(row) {
        return (
          <NTag type={row.status ? "success" : "error"}>
            {row.status ? "启用" : "停用"}
          </NTag>
        );
      },
    },
    {
      title: "描述",
      key: "remark",
      width: 200,
      ellipsis: { tooltip: true },
    },
  ];

  return { columns };
};
